package com.example.rpcconsumerdemo;

import com.example.rpcproviderdemo.jacksondemo.service.IShopRpc;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@Slf4j
@EnableDubboConfig
@SpringBootApplication
public class RpcConsumerDemoApplication {


    @DubboReference(
            version = "1.0.0",
            group = "shop",
            timeout = 100,
            methods = {
                    @Method(name = "sayHello", timeout = 300),
                    @Method(name = "ping", timeout = 200),
                    @Method(name = "test3", timeout = 200),
            }
    )
    private IShopRpc shopService;

    public static void main(String[] args) {
        SpringApplication.run(RpcConsumerDemoApplication.class, args);
    }

    @Bean
    public ApplicationRunner runner() {
        return args ->{
            log.warn(shopService.ping());
            log.warn(shopService.sayHello("mercyblitz"));
            log.info(shopService.test3(123456));
        };
    }
}
